//------------------------------------------------------------------------------
// Copyright (c) 2008 www.dnaide.com
// Licensed under the MIT (MIT-LICENSE.txt)
//------------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;

namespace DNAide.Drawing
{
	/// <summary>
	/// Used to set graphics settings on helper methods that create a new image e.g. Resize, CreateTextBitmap etc.
	/// </summary>
	[Serializable]
	public class GraphicsSettings
	{

		private CompositingMode _compositingMode;
		private CompositingQuality _compositingQuality;
		private InterpolationMode _interpolationMode;
		private PixelOffsetMode _pixelOffsetMode;
		private SmoothingMode _smoothingMode;
		private int _textContrast;
		private TextRenderingHint _textRenderingHint;

		/// <summary></summary>
		public CompositingMode CompositingMode
		{
			get { return _compositingMode; }
			set { _compositingMode = value; }
		}

		/// <summary></summary>
		public CompositingQuality CompositingQuality
		{
			get { return _compositingQuality; }
			set { _compositingQuality = value; }
		}

		/// <summary></summary>
		public InterpolationMode InterpolationMode
		{
			get { return _interpolationMode; }
			set { _interpolationMode = value; }
		}

		/// <summary></summary>
		public PixelOffsetMode PixelOffsetMode
		{
			get { return _pixelOffsetMode; }
			set { _pixelOffsetMode = value; }
		}

		/// <summary></summary>
		public SmoothingMode SmoothingMode
		{
			get { return _smoothingMode; }
			set { _smoothingMode = value; }
		}

		/// <summary></summary>
		public Int32 TextContrast
		{
			get { return _textContrast; }
			set { _textContrast = value; }
		}

		/// <summary></summary>
		public TextRenderingHint TextRenderingHint
		{
			get { return _textRenderingHint; }
			set { _textRenderingHint = value; }
		}

		/// <summary></summary>
		public GraphicsSettings()
		{
			_compositingMode = CompositingMode.SourceOver;
			_compositingQuality = CompositingQuality.Default;
			_interpolationMode = InterpolationMode.Default;
			_pixelOffsetMode = PixelOffsetMode.Default;
			_smoothingMode = SmoothingMode.Default;
			_textContrast = 0;
			_textRenderingHint = TextRenderingHint.SystemDefault;
		}

		/// <summary>Applies settings to a Graphics object</summary>
		public void ApplySettings(Graphics graphics)
		{
			if (graphics == null)
			{
				return;
			}
			graphics.CompositingMode = _compositingMode;
			graphics.CompositingQuality = _compositingQuality;
			graphics.InterpolationMode = _interpolationMode;
			graphics.PixelOffsetMode = _pixelOffsetMode;
			graphics.SmoothingMode = _smoothingMode;
			graphics.TextContrast = _textContrast;
			graphics.TextRenderingHint = _textRenderingHint;
		}


	}
}
